package com.bwie.redkids.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;

import com.bwie.redkids.R;
import com.bwie.redkids.bean.Favorites;

public class CollectListBaseAdapter extends BaseAdapter implements ListAdapter {

	private ArrayList<Favorites> query;
	private Context context;

	public CollectListBaseAdapter(Context context, ArrayList<Favorites> query) {
		this.context = context;
		this.query = query;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return query.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return query.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = View.inflate(context, R.layout.shopping_list_item,
					null);
			holder.iv_shopping_img = (ImageView) convertView
					.findViewById(R.id.collect_img);
			holder.iv__shopping_title = (TextView) convertView
					.findViewById(R.id.collect_name);
			holder.tv_shopping_nowPrice = (TextView) convertView
					.findViewById(R.id.collect_price);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		// BitmapUtils bitmapUtils = new BitmapUtils(context);
		// bitmapUtils.display(holder.iv_shopping_img, query.get(position)
		// .);
		holder.iv__shopping_title.setText(query.get(position).getName());
		holder.tv_shopping_nowPrice.setText(query.get(position).getState());
		// holder.tv_shopping_count.setText(arrayList.get(position).getCount());
		return convertView;
	}

	class ViewHolder {
		ImageView iv_shopping_img;
		TextView iv__shopping_title;
		TextView tv_shopping_nowPrice;
		TextView tv_shopping_oldPrice;
		TextView tv_shopping_count;
	}
}
